package lifeDomain;

import android.util.Log;
import support.Variables;


public class State {
	public int value;
	public int state;
	public int preValue;
	public static final int STATE_UNKNOWN = -9999;
	public static final int STATE_LOCATION = 1;
	public static final int STATE_GPS =2;
	public static final int STATE_GPRS=3;
	public static final int STATE_WIFI=4;
	public static final int STATE_BRIGHTNESS=5;
	public static final int STATE_BLUETOOTH=6;
	public static final int STATE_SOUND=7;
	public static final int STATE_HEADSET=8;
	public static final int STATE_DOCKING = 9;
	public static final int STATE_PLUGGED=10;
	public static final int STATE_GYRO=11;
	public static final int STATE_ACCEL=12;
	public static final int STATE_MSG=13;
	public static final int STATE_APP=14;
	public static final int STATE_PROXIMITY=15;
	public static final int STATE_TEMPERATURE=16;
	public static final int STATE_HUMIDITY=17;
	public static final int STATE_ATOMOSPHERE=18;
	public static final int STATE_TIMEOFDAY =19;
	public static final int STATE_DAYOFWEEK=20;
	public static final int STATE_DAYOFMONTH=21;
	public static final int STATE_OVERFLOW=22;
	
	//VALUE TYPE
	public static final int VALUE_UNKNOWN = -9999;
	
	//RESULT TYPE 
	
	public static final int RESULT_UNKNOWN = -1;
	public static final int RESULT_OK = 0;
	public static final int RESULT_DIFFERENT = 1;
	
	public State()
	{
		state = STATE_UNKNOWN;
		
	}
	public int compareTo(State ss)
	{
		if(state != ss.state)
			return RESULT_UNKNOWN;

		if(value == ss.value)
		{
			return RESULT_OK;
		}
		return RESULT_DIFFERENT;
	}
	public boolean isSameType(State ss)
	{
		if(state == ss.state)
			return true;
		return false;
	}
	
	public void Set(int _state, int _value)
	{
		if(_state >= STATE_OVERFLOW || _state <= 0)
		{
			Log.e(Variables.tag, "Out of state index..");
			return;
		}
		state = _state;
		preValue = VALUE_UNKNOWN;
		value = _value;
	}
	public State(int _state, int _value)
	{
		Set(_state, _value);
	}
	public boolean isUserTrigger()
	{
		if(state == STATE_LOCATION ||
				state == STATE_DAYOFMONTH ||
				state == STATE_DAYOFWEEK ||
				state == STATE_TIMEOFDAY)
		{
			return false;
		}
		return true;
	}
	/*
	public String toString()
	{
		String res = "";
		if(state == STATE_OVERFLOW || state == STATE_UNKNOWN)
		{
			return "Unknwon";
		}
		switch(state)
		{
		case STATE_LOCATION:		
		case STATE_GPS:
		case STATE_GPRS:
		case STATE_WIFI:
		case STATE_BRIGHTNESS:
		case STATE_BLUETOOTH:
		case STATE_SOUND:
		case STATE_HEADSET:
		case STATE_DOCKING:
		case STATE_PLUGGED:
		case STATE_GYRO:
		case STATE_ACCEL:
		case STATE_MSG:
		case STATE_APP:
		case STATE_PROXIMITY:
		case STATE_TEMPERATURE:
		case STATE_HUMIDITY:
		case STATE_ATOMOSPHERE:
		case STATE_TIMEOFDAY:
		case STATE_DAYOFWEEK:
		case STATE_DAYOFMONTH:
		case STATE_OVERFLOW:
			
		}
		
		
		return res;
		
	}
	*/
	
}
